package nl.nhl.idp.Views;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.content.Context;
import android.text.Html;
import android.util.AttributeSet;
import android.widget.TextView;

public class LogTextView extends TextView
{
	StringBuffer strBuffer;
	
    public LogTextView(Context context) {
        this(context, null, 0);
    }
    
    public LogTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
    
    public LogTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

	public void AddLog(String text) {
		String styledText = "<b><font color=yellow>" + getCurrentTime() + "</font></b>" + 
							"<b><font color=red>"+ text + "</font></br>";
		super.append(Html.fromHtml(styledText).toString() +"\n");
	}

	public String getCurrentTime()
    {   
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        Calendar c1 = Calendar.getInstance(); // today
    	
    	// return hours:minutes:seconds
    	return "[" + sdf.format(c1.getTime()) + "] ";
    }
}
